import 'package:flutter/material.dart';
import 'package:flutter_chubao/tools/app_textstyle.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class APPAlertDialog extends StatelessWidget {
  final String infoStr;
  final Function(int index) actionBtns;
  final String? contentStr;
  final String? titStr;
  final Widget? infoWidet;
  final String? leftStr;
  final String? rightStr;
  APPAlertDialog(
      {this.titStr,
      required this.infoStr,
      required this.actionBtns,
      this.infoWidet,
      this.leftStr,
      this.rightStr,
      this.contentStr});
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        padding:
            EdgeInsets.only(left: 20.w, right: 20.w, top: 40.w, bottom: 20.w),
        margin: EdgeInsets.symmetric(horizontal: 30.w),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(10),
          color: Colors.white,
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            titStr != null
                ? Container(
                    margin: EdgeInsets.only(bottom: 15.w),
                    child: Text(
                      titStr ?? '',
                      style: AppTextStyle.getBoldTextStyle(fontSize: 18),
                    ),
                  )
                : const SizedBox(),
            infoWidet ??
                Text(
                  infoStr,
                  style: AppTextStyle.getNormalTextStyle(fontSize: 16),
                ),
            contentStr != null
                ? Container(
                    margin: EdgeInsets.only(top: 5.w),
                    child: Text(
                      contentStr ?? '',
                      style: AppTextStyle.getNormalTextStyle(
                          fontSize: 12, color: Colors.black45),
                    ),
                  )
                : const SizedBox(),
            SizedBox(
              height: 18.w,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                GestureDetector(
                  onTap: () async {
                    actionBtns.call(0);
                    Get.back();
                  },
                  child: Container(
                    width: 125.w,
                    height: 40.w,
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(5),
                        border: Border.all(
                            width: 1, color: const Color(0xff6A76FF))),
                    child: Text(leftStr ?? '取消',
                        style: AppTextStyle.getNormalTextStyle(
                            fontSize: 16, color: Color(0xff6A76FF))
                        // .copyWith(color: const Color(0xff6A76FF)),
                        ),
                  ),
                ),
                GestureDetector(
                  onTap: () async {
                    Get.back();
                    await Future.delayed(Duration.zero);
                    actionBtns.call(1);
                  },
                  child: Container(
                    width: 125.w,
                    height: 40.w,
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(5),
                        color: const Color(0xff6A76FF)),
                    child: Text(
                      rightStr ?? '确定',
                      style: AppTextStyle.getBoldTextStyle(
                          fontSize: 16, color: Colors.white),
                    ),
                  ),
                )
              ],
            )
          ],
        ),
        // child: Column(
        //   crossAxisAlignment: cro,
        //   children: [

        //   ],
        // ),
      ),
    );
  }
}
